VPAAMP-163: Latency is fluctuating during normal playback in Linear/SLE assets#1412
VPAAMP-163: Latency is fluctuating during normal playback in Linear/SLE assets#1412psiva01 wants to merge 6 commits into
Conversation
Signed-off-by: psiva01 <sivasubramanian.patchaiperumal@ltts.com>
Signed-off-by: psiva01 <sivasubramanian.patchaiperumal@ltts.com>
Signed-off-by: psiva01 <sivasubramanian.patchaiperumal@ltts.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses fluctuating HLS live latency reporting by switching the latency calculation from “live edge position delta” (which advances in segment-sized steps per playlist refresh) to a Program Date Time (PDT)-based wall-clock calculation when EXT-X-PROGRAM-DATE-TIME is available.
Changes:
- Add a PDT-based HLS live latency calculation path using
mProgramDateTimeand current epoch time. - Keep the prior live-edge-based latency calculation as a fallback when PDT is unavailable.
- Add detailed logging around the new PDT latency computation.
| // to guard against transient position-behind-start edge cases. | ||
| double playbackOffsetFromWindowStartMs = reportFormattedCurrPos - (culledSeconds*1000.0); | ||
| if (playbackOffsetFromWindowStartMs < 0.0) | ||
| { | ||
| playbackOffsetFromWindowStartMs = 0.0; | ||
| } | ||
| long long pdtAtCurrentPosMs = static_cast<long long>( | ||
| (mProgramDateTime * 1000.0) + playbackOffsetFromWindowStartMs); |
There was a problem hiding this comment.
@copilot apply changes based on this feedback and #1412 (comment)
There was a problem hiding this comment.
Fixed in cd37ddd. Changed playbackOffsetFromWindowStartMs from reportFormattedCurrPos - (culledSeconds*1000.0) (mixed coordinate spaces) to position - (culledSeconds * 1000.0) — both in the same raw (unadjusted) space. Using position directly (rather than reportFormattedCurrPos - start) also avoids the edge case where start is reset to -1 for TSB-less linear streams. Also updated the block comment and downgraded the log from WARN to INFO.
| long long pdtAtCurrentPosMs = static_cast<long long>( | ||
| (mProgramDateTime * 1000.0) + playbackOffsetFromWindowStartMs); | ||
| latency = static_cast<long>(nowMs - pdtAtCurrentPosMs); | ||
| AAMPLOG_WARN("HLS PDT latency = %ldms, nowMs = %lldms, mProgramDateTime = %.3fs, " |
| latency, nowMs, mProgramDateTime, start, culledSeconds*1000.0, reportFormattedCurrPos, playbackOffsetFromWindowStartMs); | ||
| if(latency < 0) | ||
| { // this should never happen! | ||
| AAMPLOG_ERR("HLS PDT-based negative live latency = %ldms, nowMs = %lldms, pdtAtCurrentPosMs = %lldms", latency, nowMs, pdtAtCurrentPosMs); |
| { | ||
| // For HLS Live, calculate latency based on live edge; round to nearest ms | ||
| latency = static_cast<long>(std::lround(end - reportFormattedCurrPos)); | ||
| if(latency < 0) | ||
| { // this should never happen! | ||
| AAMPLOG_ERR("HLS negative live latency = %ldms, end = %lfms, reportFormattedCurrPos = %lfms", latency, end, reportFormattedCurrPos); | ||
| if(mProgramDateTime > 0.0) | ||
| { | ||
| // For HLS Live with EXT-X-PROGRAM-DATE-TIME: calculate latency as the | ||
| // difference between the current wall-clock time and the absolute wall-clock | ||
| // time at the player's current playback position. | ||
| // mProgramDateTime is the current playlist-window start in epoch seconds. | ||
| // reportFormattedCurrPos is the player's position in ms, measured from the | ||
| // same window start (i.e. relative to culledSeconds). Adding them together |
…ttedCurrPos Agent-Logs-Url: https://github.com/rdkcentral/aamp/sessions/5852c16e-2ee2-4038-93f1-c2e2942fe7f1 Co-authored-by: psiva01 <214551386+psiva01@users.noreply.github.com>
Reason for Change: Current HLS latency is fluctuating because it's based on playlist end position which gets updated by 0/4/8s during every refresh. Change HLS Latency calculation based on PDT which is gradual.